<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Tax extends CI_Controller {

 function __construct()
 {
   parent::__construct();
   $this->load->model('muser');
   $this->load->library('form_validation');
   $this->load->library('pagination');
 }
 function index(){	
	 $roles=$this->session->userdata('roles');
 	 $config['base_url'] = base_url().'tax/index'; 
	 $config['total_rows'] = $this->muser->num_rows('Tax');
	 
	 $config['per_page'] =20; // xác định số record ở mỗi trang  
     $config['uri_segment'] = 3; // xác định segment chứa page number  
	 $this->pagination->initialize($config); 
	 $data['result']=$this->muser->getalldata('Tax',$config['per_page'],$this->uri->segment(3));	
	 $result=$this->muser->getMax('Tax');
	 $data['EDate']=$result->EffectiveDate;
         if($roles==0||$roles==1)
         {
	 $this->load->view('_header');
     $this->load->view('tax/tax_view',$data); 
     $this->load->view('_footer');
         }
     else
         {
             $data['ban_roles']="You haven't this role";
             $this->load->view('_header',$data);
             $this->load->view('notAllowRole');
             $this->load->view('_footer');
         }
 }
 function insert(){
 		$DT=array(					
					"Tax_ID"=>$this->input->post('Tax_ID'),
					"From"=>$this->input->post('From'),
					"To"=>$this->input->post('To'),
					"Percent"=>$this->input->post('Percent'),					
					"EffectiveDate"=>$this->input->post('EffectiveDate')				
			);	
		$this->muser->addData('Tax',$DT);
		$data['error']='Insert successful!';
		redirect('tax/index');
 }
 function delete($Tax_ID){ 	
 		$this->muser->delColumn('Tax','Tax_ID',$Tax_ID);
		redirect('tax/index'); 			
	
 }
 function edit1 ()
 {
 	$DT=array(
					"Tax_ID"=>$this->input->post('Tax_ID'),
					"From"=>$this->input->post('From'),
					"To"=>$this->input->post('To'),
					"Percent"=>$this->input->post('Percent'),					
					"EffectiveDate"=>$this->input->post('EffectiveDate')				
			);	
	$this->muser->updateData('Tax','Tax_ID',$DT['Tax_ID'],$DT);
	$data['error']='Edit successful!';	 	
	redirect('tax/index');		
 } 
 function edit($str)
 {	
 	$result=$this->muser->getRdata('Tax','Tax_ID',$str);
	$data['result']=$result;	
 	$this->load->view('_header');
	$this->load->view('tax/editTax_view',$data);	
	$this->load->view('_footer');
 }
 
 function check_Tax($str){
 		return $this->muser->checkData('Tax','Tax_ID',$str);		
 }
 }